const toastr = {
	timeout:null,
	msg(string){
		mpvue.showToast({title: string || 'no error msg',icon:'none'})
		this.hideToast()
	},
	success(string){
		mpvue.showToast({title: string || 'no error msg'})
		this.hideToast()
	},
	
	showLoading(string){
		mpvue.showLoading({title:string ,mask:true})
	},
	hideLoading(){
		this.timeout = setTimeout(()=>{
			mpvue.hideLoading()
		},1000)
	},
	clearTimeout(){
		if (this.timeout) {
			clearTimeout(this.timeout)
		}
	},
	hideToast(){
		setTimeout( () =>{
			mpvue.hideToast();  
		},2000)
	}
}

export default {
	install: function(Vue, Option) {
		Object.defineProperty(Vue.prototype, "$toastr", { value: toastr });
	},
	toastr:toastr
};